Skip to content

fix: resolve workflow_install_note.md ENOENT in safe_outputs job#33654

Merged
pelikhan merged 3 commits into
mainfrom
copilot/bugfix-workflow-install-note
May 21, 2026
Merged

fix: resolve workflow_install_note.md ENOENT in safe_outputs job#33654
pelikhan merged 3 commits into
mainfrom
copilot/bugfix-workflow-install-note

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 21, 2026

When create_pull_request safe-output touches .github/workflows/ files, the safe_outputs job crashes with ENOENT: no such file or directory, open '…/gh-aw/md/workflow_install_note.md'. The template is deployed to ${RUNNER_TEMP}/gh-aw/prompts/ by setup.sh, but messages_footer.cjs was resolving it via path.join(__dirname, "../md/…") — which is valid from the source tree but resolves to the non-existent .../safeoutputs/../md/ when deployed.

Changes

  • messages_footer.cjs — Import getPromptPath from messages_core.cjs and use it to resolve workflow_install_note.md at runtime, falling back to the source-tree path for local dev (mirrors the pattern in firewall_blocked_domains.cjs):

    // Before
    const defaultInstallTemplatePath = path.join(__dirname, "../md/workflow_install_note.md");
    
    // After
    const hasRuntimePromptsDir = !!(process.env.RUNNER_TEMP || process.env.GH_AW_PROMPTS_DIR);
    const defaultInstallTemplatePath = hasRuntimePromptsDir
      ? getPromptPath("workflow_install_note.md")
      : path.join(__dirname, "../md/workflow_install_note.md");
  • messages.test.cjs, close_entity_helpers.test.cjs, pr_review_buffer.test.cjs — Set GH_AW_PROMPTS_DIR to the source md/ directory in test setup so getPromptPath() resolves against the source tree when RUNNER_TEMP is set in CI.

…safe_outputs

The messages_footer.cjs file was using a hardcoded relative path
(path.join(__dirname, "../md/workflow_install_note.md")) to read the
workflow install note template. When running in the safe_outputs job,
__dirname is ${RUNNER_TEMP}/gh-aw/safeoutputs, so the path resolves to
${RUNNER_TEMP}/gh-aw/md/workflow_install_note.md which doesn't exist.

The template is actually deployed to ${RUNNER_TEMP}/gh-aw/prompts/ by
setup.sh. Fix this by using getPromptPath() (which resolves via
RUNNER_TEMP or GH_AW_PROMPTS_DIR) with a fallback to the source tree
path for local dev/test environments — the same pattern used in
firewall_blocked_domains.cjs.

Update affected test files to set GH_AW_PROMPTS_DIR to the source md/
directory so tests can find template files when RUNNER_TEMP is set in
the CI environment.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ENOENT error in safe_outputs when workflow files are modified fix: resolve workflow_install_note.md ENOENT in safe_outputs job May 21, 2026
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot remove fallback, use get prompt path

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 21, 2026

@copilot remove fallback, use get prompt path

Done — removed the hasRuntimePromptsDir fallback and the now-unused path require; messages_footer.cjs now calls getPromptPath("workflow_install_note.md") directly. Committed in the latest push.

@pelikhan pelikhan marked this pull request as ready for review May 21, 2026 01:00
Copilot AI review requested due to automatic review settings May 21, 2026 01:00
@pelikhan pelikhan merged commit 6014610 into main May 21, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/bugfix-workflow-install-note branch May 21, 2026 01:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an ENOENT crash in the safe_outputs job when resolving workflow_install_note.md after deployment by switching footer template resolution to the runtime prompts directory, and adjusts unit tests to ensure getPromptPath() resolves templates correctly in CI.

Changes:

  • Update messages_footer.cjs to resolve workflow_install_note.md via getPromptPath().
  • Update multiple Vitest suites to set GH_AW_PROMPTS_DIR to the source md/ directory during tests.
  • Add env restoration in pr_review_buffer.test.cjs for GH_AW_PROMPTS_DIR.
Show a summary per file
File Description
actions/setup/js/messages_footer.cjs Switches install-note template lookup to runtime prompt resolution.
actions/setup/js/messages.test.cjs Sets GH_AW_PROMPTS_DIR in test setup to make prompt resolution deterministic in CI.
actions/setup/js/close_entity_helpers.test.cjs Sets GH_AW_PROMPTS_DIR in test setup to avoid missing prompt templates in CI.
actions/setup/js/pr_review_buffer.test.cjs Sets and restores GH_AW_PROMPTS_DIR during tests.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 3

Comment on lines 132 to 136
const templateContext = toSnakeCase({ ...ctx, agenticWorkflowUrl });

const defaultInstallTemplatePath = path.join(__dirname, "../md/workflow_install_note.md");
const defaultInstallTemplatePath = getPromptPath("workflow_install_note.md");

// Use custom installation message if configured
Comment on lines +41 to 46
// Point GH_AW_PROMPTS_DIR to the source md/ directory so getPromptPath()
// resolves template files from the source tree in test environments where
// RUNNER_TEMP is set but the runtime prompts directory is not populated.
process.env.GH_AW_PROMPTS_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "../md");
// Clear cache by reimporting
vi.resetModules();
Comment on lines +18 to 22
// Point GH_AW_PROMPTS_DIR to the source md/ directory so getPromptPath()
// resolves template files from the source tree in test environments where
// RUNNER_TEMP is set but the runtime prompts directory is not populated.
(process.env.GH_AW_PROMPTS_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "../md")),
(global.context.eventName = "issues"),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: workflow_install_note.md ENOENT in safe_outputs when PR touches workflow files

3 participants